﻿using System.Collections.Generic;
using System.Web.Mvc;
using SinBiota.Model.Business.AuthenticationServices.Interfaces;
using SinBiota.Model.Business.PersistenceServices.Interfaces;
using SinBiota.Model.Entities;
using Sinbiota.Web.ActionFilters;

namespace Sinbiota.Web.Controllers
{

    [AdminPermission]
    public class AdministrationController : BaseController
    {
        //
        // GET: /Administration/
        
        private readonly IOccurrencePersistenceServices _occurrencePersistenceServices;

        public AdministrationController(IOccurrencePersistenceServices occurrencePersistenceServices)
        {
            _occurrencePersistenceServices = occurrencePersistenceServices;
        }

        public ActionResult Index()
        {
            return View("Index", AdminEntities());
        }

        public ActionResult InitOccurrenceSpatialDatabase()
        {
            _occurrencePersistenceServices.InitOccurrenceSpatialDatabase();

            return View("Success");

        }

        private static IList<BaseEntity> AdminEntities()
        {
            return new List<BaseEntity> { 
                new Project(),
                new User(), 
                new ConservationUnit(), 
                new DepositaryUnit(),
                new DrainageBasin(), 
                new Ecosystem(), 
                new Habitat(), 
                new Institution(), 
                new Keyword(), 
                new Method(),
                new MicroHabitat(), 
                new Publication(),
                new Municipality(),
                
            };
        }
    }
}
